package pjkanri.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class LogoutServlet
 */
@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		// リクエスト・パラメーターの取得

		String forwardPath = "index.jsp";
		// セッション管理開始
		HttpSession session = request.getSession();
		// セッション・オブジェクトにAccountオブジェクトをセット
		session.setAttribute("account", null);

		// 転送処理
		request.getRequestDispatcher(forwardPath).forward(request, response);
	}
}
